package principle.singleResponsibility;

/**
 * @author lcy
 * @date 2024/7/12 17:21
 */
public class Responsibility3 {
    public static void main(String[] args) {
        Vehicle2 vehicle2 = new Vehicle2();
        vehicle2.run("汽车");
        vehicle2.runAir("飞机");
        vehicle2.runWater("轮船");
    }
}
/*
* 1.没有对原来的类大修改，只是增加了方法
* 2.虽然没有在类级别上遵守单一原则，但是方法级别上遵守了
* 3. 直接修改Vehicle类，改动少，能保证方法上的单一原则
* */

class Vehicle2{

    public void run(String vehicle){
        System.out.println(vehicle + "在地上跑");
    }

    public void runAir(String vehicle){
        System.out.println(vehicle + "在天上飞");
    }

    public void runWater(String vehicle){
        System.out.println(vehicle + "在水上游");
    }
}
